//tesr inti loadUi and actions & run
//connect quit to action signal and programatically hit the action
//later test can associate key press and have that happen programatically
//right now exit the test by hitting the file ioen icon on the toolbar


#include <stdio.h>
#include <stdlib.h>

#include "euqt.h"
#include "../euqt_test.h"


//from quiviewer probably from one of the qt forums? qwwuiviewer?
QString ui = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
	"<ui version=\"4.0\" >"
	" <class>MainWindow</class>"
	" <widget class=\"QMainWindow\" name=\"MainWindow\" >"
	"  <property name=\"geometry\" >"
	"   <rect>"
	"    <x>0</x>"
	"    <y>0</y>"
	"    <width>191</width>"
	"    <height>83</height>"
	"   </rect>"
	"  </property>"
	"  <property name=\"windowTitle\" >"
	"   <string>QUiViewer</string>"
	"  </property>"
	"  <widget class=\"QWidget\" name=\"centralwidget\" />"
	"  <widget class=\"QMenuBar\" name=\"menubar\" >"
	"   <property name=\"geometry\" >"
	"    <rect>"
	"     <x>0</x>"
	"     <y>0</y>"
	"     <width>191</width>"
	"     <height>29</height>"
	"    </rect>"
	"   </property>"
	"   <widget class=\"QMenu\" name=\"menuFile\" >"
	"    <property name=\"title\" >"
	"     <string>&amp;File</string>"
	"    </property>"
	"    <addaction name=\"actionOpenFile\" />"
	"    <addaction name=\"actionExit\" />"
	"   </widget>"
	"   <addaction name=\"menuFile\" />"
	"  </widget>"
	"  <widget class=\"QStatusBar\" name=\"statusbar\" />"
	"  <widget class=\"QToolBar\" name=\"toolBar\" >"
	"   <property name=\"orientation\" >"
	"    <enum>Qt::Horizontal</enum>"
	"   </property>"
	"   <attribute name=\"toolBarArea\" >"
	"    <number>4</number>"
	"   </attribute>"
	"   <addaction name=\"actionOpenFile\" />"
	"  </widget>"
	"  <action name=\"actionOpenFile\" >"
	"   <property name=\"text\" >"
	"    <string>Exit App</string>"
	"   </property>"
	"  </action>"
	"  <action name=\"actionExit\" >"
	"   <property name=\"text\" >"
	"    <string>Exit</string>"
	"   </property>"
	"  </action>"
	" </widget>"
	" <resources/>"
	" <connections/>"
	"</ui>";



class dlgTest: public QObject
{
	Q_OBJECT
private slots:
	void testOne();
};

void dlgTest::testOne()
{
	QApplication *q = qt_init(0,(char**)0);  //~ argc, argv
	QWidget *w = qt_loadUi((char *)(ui.toUtf8().data()), 0);
	QVERIFY(w != 0);


	QWidget *qmf = qt_findChild(w, "actionOpenFile", "QAction");
	QVERIFY(qmf != 0);
	QObject::connect(qmf, SIGNAL(triggered()), q, SLOT(quit()));



	qt_show(w);

//~ QTest::keyClick(myWidget, 'a');


	QVERIFY(qt_run(0) == 0);
}


    //~ QLineEdit lineEdit;
    //~ QTest::keyClicks(&lineEdit, "hello world");
    //~ QCOMPARE(lineEdit.text(), QString("hello world"));




QTEST_MAIN(dlgTest)
#include "dlgtest.moc"

